package org.liaohailong.helloworld;

import org.junit.Test;
import org.liaohailong.helloworld.array.StringSolution;
import org.liaohailong.helloworld.example.TX;

import java.util.Arrays;

/**
 * Author: liaohailong
 * Time: 2021/5/12 09:46
 * Describe:
 */
public class Exam3 implements AUtil.ILog {

    @Test
    public void findMind() {
        AUtil.setLog(this);
        StringSolution ss = new StringSolution();
//        int[] nums = new int[]{4, 5, 6, 7, 0, 1, 2};
//        int[] nums = new int[]{11, 13, 15, 17};
//        int[] nums = new int[]{1};
//        int[] nums = new int[]{2,3,4,5,1};
        int[] nums = new int[]{2, 3, 4, 5, 6, 1};
        int min = ss.findMin(nums);
        log("min = " + min);
    }

    @Test
    public void removeDuplicates() {
        AUtil.setLog(this);
        StringSolution ss = new StringSolution();
        int[] nums = new int[]{0, 0, 1, 1, 1, 2, 2, 3, 3, 4};
        int count = ss.removeDuplicates(nums);
        log("count = " + count);
    }

    @Test
    public void moveZeroes() {
        AUtil.setLog(this);
        StringSolution ss = new StringSolution();
        int[] nums = new int[]{0, 1, 0, 3, 12};
        ss.moveZeroes(nums);
        log(Arrays.toString(nums));
    }

    @Test
    public void findMin() {
        // [4,3,0,1] 2
        // [5,4,3,2,1,0] 6
        // [4,3,2] 0
//        int[] arr = {4, 3, 0, 1};
//        int[] arr = {5,4,3,2,1,0};
        int[] arr = {4,3,2};
        int min = TX.findMin(arr);
        log("min = " + min);
    }


    public void log(String msg) {
        log("Exam1", msg);
    }

    @Override
    public void log(String tag, String msg) {
        System.out.println(tag + ": " + msg);
    }
}
